package com.shop.shopserver.config;

import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.teaopenapi.models.*;
import com.shop.shopcommon.properties.AliSmsProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AliSmsConfiguration {
    // 创建阿里云短信服务客户端实例
    @Bean
    public Client aliyunSmsClient(AliSmsProperties aliSmsProperties) throws Exception {
        Config config = new Config()
                .setAccessKeyId(aliSmsProperties.getAccessKeyId())
                .setAccessKeySecret(aliSmsProperties.getAccessKeySecret());
        config.endpoint = aliSmsProperties.getRegionId();
        return new Client(config);
    }
}
